package com.example.demo.design_patterns.Strategy;

/**
 * 环境角色（类似于TreeSet）
 *
 * @author: htc
 * @date: Created in 18:06 2019/3/12.
 */
public class Environment {
    /**
     * 持有对策略类的引用
     */
    private Strategy strategy;

    /**
     * 类似于TreeSet
     * @param strategy
     */
    public Environment(Strategy strategy) {
        this.strategy = strategy;
    }

    public int caculate(int a, int b) {
        return strategy.calc(a, b);
    }
}
